<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>地址核验</title>
		<link rel="stylesheet" type="text/css" href="css/index.css" />
		<!-- <link rel="stylesheet" type="text/css" href="http://mishengqiang.com/sweetalert/css/sweetalert.css"> -->
		<!-- <link rel="stylesheet"  href="https://cdn.jsdelivr.net/npm/sweetalert2@11.12.2/dist/sweetalert2.min.css"> -->
		
		<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.5.0/dist/sweetalert2.all.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.css" id="theme-styles">
	  
	  

	</head>

	<body>

		<div class="form-structor">
			<!-- logo -->
			<div class="logo">
				<img src="img/logo.jpg" />
			</div>
			<!-- 登录 -->
			<div class="longin">
				<div class="longin-boder">
					<div class="image"><img src="img/yh2.png"></div>
					<input class="input" type="text" placeholder="输入用户名/手机号" id="usr" />
				</div>
				<!--End用户名输入框-->
				<div class="longin-boder">
					<div class="image"><img src="img/mm1.png"></div>
					<input class="input" type="password" placeholder="用户密码" id="pwd" />
				</div>
				<!--End密码输入框-->
				<div class="button" id="btn">登录</div>
			</div>
		</div>

		<!-- <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.12.2/dist/sweetalert2.all.min.js"></script> -->
		<!-- <script type="text/javascript" src="http://mishengqiang.com/sweetalert/js/sweetalert-dev.js"></script> -->
		<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
		<script>
			//这里面是屏幕适配的所有源码 复制这里面粘贴即可 样式可随便写 这里屏幕最大宽度为750px
			fixLayout() //初始执行一次
			window.addEventListener("resize", fixLayout); //监测屏幕大小改变时触发fixLayout方法
			//fixLayout方法添加一个meta屏幕大小适配标签
			function fixLayout() {
				const width = window.screen.width; //屏幕的宽度；
				const fixW = 750; //设置750则所有屏幕宽度都为750px
				const scale = width / fixW; // scale比例,这个比例会根据你写的内容px大小对应乘以这个比例得到响应屏幕的真正px值
				const meta = document.createElement("meta")
				meta.setAttribute("name", "viewport")
				meta.setAttribute("content", `width=device-width, initial-scale=${scale},user-scalable=no`)
				if (document.head.childNodes[14]) document.head.removeChild(document.head.childNodes[14]);
				document.head.appendChild(meta)
			}
		</script>

		 <!-- 模块脚本 -->
		 <script type="module">
			import API_CONFIG from './apiConfig.js';
			
			// 使用API_CONFIG的代码
			console.log(API_CONFIG.LOGIN_URL);
		  </script>

	</body>
	<script src="js/js.js"></script>
	<script>
		! function() {
			if (/iphone|ios|android|ipod/i.test(navigator.userAgent.toLowerCase()) == false) {
				location.href = 'indexpc.html';
			}
		}();
		var btn = document.getElementById("btn")
		var usr = document.getElementById("usr")
		var pwd = document.getElementById("pwd")
		// document.getElementById('swe').style.backgroundColor = '16px';
		var mo = function(e) {
			e.preventDefault();
		};
		function stop() {
			document.body.style.overflow = 'hidden';
			document.addEventListener("touchmove", mo, false); //禁止页面滑动
		}
		stop()
		// 页面恢复
		$("input").on("blur",function(){
		    window.scroll(0,0);
		});
		btn.onclick = function() {
			if (usr.value == "") {
				swal.fire({
					title: "Error",
					text: "请输入账号",
					// type: "error",
					confirmButtonText: "确 定"
				}).then(result => {
					if(result.isConfirmed)
						swal.fire("Done!", "It was succesfully deleted!", "success");
					else
						swal.fire("Error!", "Coudn't delet!", "error");
				});
			} else if (pwd.value == "") {
				swal.fire({
					title: "Error",
					text: "请输入密码",
					// type: "error",
					confirmButtonText: "确 定"
				});
			} else {
				let url = API_CONFIG.LOGIN_URL; //"http://101.201.73.103:8001/bd/sys/doLogin";
				let data = {
					password: pwd.value,
					username: usr.value,
				};
				Ajax.post(url, JSON.stringify(data), function(res) {

					window.localStorage.setItem('TOken', JSON.parse(res).data)
					if (JSON.parse(res).code != 0) {
						swal.fire({
							title: "error",
							text: JSON.parse(res).message,
							// type: "error",
							confirmButtonText: "确 定"
						});
					} else {
						// swal.fire({
						// 		title: "success",
						// 		text: "登录成功",
						// 		// type: "success",
						// 		confirmButtonText: "确 定"
						// 	},
						// 	function(isConfirm) {
						// 		if (isConfirm) {
						// 			window.location.href = "searchpc.html";
						// 		}
						// 	}
						// )
						swal.fire({
							title: 'success!',
							text: '登录成功',
							// icon: 'error',
							confirmButtonText: '确 定'
						}).then((result) => {
							if (result.isConfirmed)
								window.location.href = "searchpc.html";
							else
								swal.fire("Error!", "Coudn't delet!", "error");
						});

					}

				})
				






			}
		};
	</script>

</html>
